package F;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        int e = sc.nextInt();
        int t = sc.nextInt();
        int a=d;
        int b=e;
        while (t-- > 0) {
            int x1 = sc.nextInt();
            int y1 = sc.nextInt();
            int x2 = sc.nextInt();
            int y2 = sc.nextInt();
            int sum = x1 + x2;
//            System.out.println(sum);
            if (y1 == y2) {
                continue;
            }
            if (y1 == sum) {
                a--;
            }
            if (y2 == sum) {
                b--;
            }
             if (a<0){
                 System.out.println("A");
                 System.out.println(e-b);
                 break;
             }
             if (b<0){
                 System.out.println("B");
                 System.out.println(d-a);
                 break;
             }
        }
    }
}
